package com.ruoyi.bizsys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.bizsys.domain.RepaymentTransfer;
import com.ruoyi.bizsys.mapper.RepaymentTransferMapper;
import com.ruoyi.bizsys.service.IRepaymentTransferService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;


/**
 * transfer还款记录Service业务层处理
 *
 * @author african-loan
 * @date 2021-12-30
 */
@Service
public class RepaymentTransferServiceImpl extends ServiceImpl<RepaymentTransferMapper, RepaymentTransfer> implements IRepaymentTransferService {

    /**
     * 查询transfer还款记录
     *
     * @param id transfer还款记录ID
     * @return transfer还款记录
     */
    @Override
    public RepaymentTransfer selectRepaymentTransferById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询transfer还款记录列表
     *
     * @param repaymentTransfer transfer还款记录
     * @return transfer还款记录
     */
    @Override
    public List<RepaymentTransfer> selectRepaymentTransferList(RepaymentTransfer repaymentTransfer) {
        return this.list(new QueryWrapper<>(repaymentTransfer).last("order by id desc"));
    }

    /**
     * 新增transfer还款记录
     *
     * @param repaymentTransfer transfer还款记录
     * @return 结果
     */
    @Override
    public int insertRepaymentTransfer(RepaymentTransfer repaymentTransfer) {
        repaymentTransfer.setCreateTime(DateUtils.getNowDate());
        return baseMapper.insert(repaymentTransfer);
    }

    /**
     * 修改transfer还款记录
     *
     * @param repaymentTransfer transfer还款记录
     * @return 结果
     */
    @Override
    public int updateRepaymentTransfer(RepaymentTransfer repaymentTransfer) {
        repaymentTransfer.setUpdateTime(DateUtils.getNowDate());
        return baseMapper.updateById(repaymentTransfer);
    }

    /**
     * 批量删除transfer还款记录
     *
     * @param ids 需要删除的transfer还款记录ID
     * @return 结果
     */
    @Override
    public int deleteRepaymentTransferByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除transfer还款记录信息
     *
     * @param id transfer还款记录ID
     * @return 结果
     */
    @Override
    public int deleteRepaymentTransferById(Long id) {
        return baseMapper.deleteById(id);
    }

}
